#include<iostream>
#include<unistd.h>
#include<string>
#include<pthread.h>
void* hhh(void* )
{
    int cnt = 10;
    while(cnt--)
    {
        std::cout << "hhh" << std::endl;
        sleep(1);
    }
    return nullptr;
}
int main()
{
    pthread_t tid;
    pthread_create(&tid,nullptr,hhh,nullptr);
    printf("%ld\n",tid);
    tid = pthread_self();
    printf("%ld\n",tid);
    sleep(2);
    pthread_cancel(tid);//将主线程取消,子线程不取消
    sleep(5);
    std::cout << "bey~~~~" << std::endl;
    //sleep(10);
    return 0;
}
//主线程会等待子线程结束后再退出